Clarification of "avoid if-else" advice [duplicate]

Posted by deviDave on Programmers See other posts from Programmers or by deviDave
Published on 2013-08-01T15:04:47Z Indexed on 2013/08/02 16:03 UTC
Read the original article Hit count: 282

Filed under:
|

This question already has an answer here:

The experts in clean code advise not to use if/else since it's creating an unreadable code. They suggest rather using IF and not to wait till the end of a method without real need.

Now, this if/else advice confuses me. Do they say that I should not use if/else at all (!) or to avoid if/else nesting?

Also, if they refer to the nesting of if/else, should I not do even a single nesting or I should limit it to max 2 nestings (as some recommends)?

When I say single nesting, I mean this:

    if (...) {

        if (...) {

        } else {

        }

    } else {

    }

EDIT

Also tools like Resharper will suggest reformatting if/else statements. It usually concerts them to if stand-alone statement, and sometimes even to ternary expression.

© Programmers or respective owner

Related posts about nesting

Related posts about if-else